package com.zui.manager;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.zui.entity.product.Product;
import com.zui.entity.product.ProductImage;
import com.zui.webapp.action.TradeAction;

/**
 * 负责整个Product模块内的业务.
 * 
 * 用@Transactional注明类里的每个方法都用事务的,对只读方法注明readOnly=true加强性能.
 * 
 * @author zhaoyong
 */
@Transactional
public class ProductManagerImpl extends EntityManagerImpl<Product, String> implements
		ProductManager {
	
	private static final Log log = LogFactory.getLog(TradeAction.class);
	
	@Autowired
	private ImageManager imageManager;	
	@Autowired
	private SessionManager sessionManager;
	
	public void deleteProductImage(ProductImage productImage) {
		productImage = (ProductImage)sessionManager.loadById(ProductImage.class, productImage.getId());
		imageManager.deleteImageFromFileSystem(productImage.getImage());
		sessionManager.deleteEntity(productImage);
	}
}
